"""
@Project ：Python_learning 
@File    ：121.买股票的最佳时机.py
@Author  ：zhupp
@Date    ：2024/12/20 16:13 
"""
from typing import List


class Solution:
    def maxProfit(self, prices: List[int]) -> int:
        max_profit = 0
        min_price = prices[0]
        for i in range(len(prices)):
            if prices[i] < min_price:
                min_price = prices[i]
            if prices[i] - min_price > max_profit:
                max_profit = prices[i] - min_price
        return max_profit



s = Solution()
print(s.maxProfit([2,4,1]))
